﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using GMS.BIZ;
using System.Collections;
using System.Data;

namespace Web.Paper
{
    public partial class WebForm7 : System.Web.UI.Page
    {
        protected void Page_LoadComplete(object sender, EventArgs e)
        {
            if (!((Account)Session["Account"]).RoleCurrent.Equals('c')) Response.Redirect("Default.aspx");
            ClassTeacher myClassTeacher = new ClassTeacher(((ClassTeacher)Session["ClassTeacher"]).TeacherId);
            if (!IsPostBack)
            {
                ArrayList arraylist = new ArrayList();
                arraylist = myClassTeacher.Classes.GetList();
                if (arraylist.Count!=0)
                {
                    for (int i = 0; i < arraylist.Count; i++)
                    {
                        ListItem myListItem = new ListItem();
                        myListItem.Text = arraylist[i].ToString();
                        myListItem.Value = myListItem.Text;
                        DropDownList_class.Items.Add(myListItem);
                    }
                }
                else DropDownList_class.SelectedItem.Text = "空";
            }
            ClassInfo myClassInfo = new ClassInfo(DropDownList_class.SelectedValue);

            /*
            DataSet testDS = myClassInfo.GetStudentsDataSetWithPaperInfo();
            Response.Write(testDS.Tables[0].Rows.Count.ToString());
             */
            DataSet ds = myClassInfo.GetStudentsDataSetWithPaperInfo();
            if (ds.Tables[0].Rows.Count!=0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    ds.Tables[0].Rows[i]["立题申报"] = DocumentStatus.GetName(int.Parse(ds.Tables[0].Rows[i]["立题申报"].ToString()));
                    ds.Tables[0].Rows[i]["任务书"] = DocumentStatus.GetName(int.Parse(ds.Tables[0].Rows[i]["任务书"].ToString()));
                    ds.Tables[0].Rows[i]["开题报告"] = DocumentStatus.GetName(int.Parse(ds.Tables[0].Rows[i]["开题报告"].ToString()));
                    ds.Tables[0].Rows[i]["论文"] = DocumentStatus.GetName(int.Parse(ds.Tables[0].Rows[i]["论文"].ToString()));
                    ds.Tables[0].Rows[i]["作品"] = DocumentStatus.GetName(int.Parse(ds.Tables[0].Rows[i]["作品"].ToString()));
                    ds.Tables[0].Rows[i]["翻译"] = DocumentStatus.GetName(int.Parse(ds.Tables[0].Rows[i]["翻译"].ToString()));
                }
                GridView_StuPaper.DataSource = ds;
                GridView_StuPaper.DataBind();
            }
            else Label_NoData.Text = "该班级没有学生论文信息";
        }

        protected void GridView_StuPaper_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            ClassTeacher myClassTeacher = new ClassTeacher(((ClassTeacher)Session["ClassTeacher"]).TeacherId);
            ClassInfo myClassInfo = new ClassInfo(DropDownList_class.SelectedValue);
            GridView_StuPaper.DataSource = myClassInfo.GetStudentsDataSetWithPaperInfo();
            GridView_StuPaper.DataBind();
        }

        //protected void GridView_StuPaper_RowDataBound(object sender, GridViewRowEventArgs e)
        //{
        //    if (e.Row.RowType == DataControlRowType.DataRow)
        //    {
        //        for (int i = 2; i < 8; i++)
        //        {
        //            switch (int.Parse(e.Row.Cells[i].Text))
        //            {
        //                case 0: e.Row.Cells[i].Text = DocumentStatus.GetName(0); break;
        //                case 1: e.Row.Cells[i].Text = DocumentStatus.GetName(1); break;
        //                case 2: e.Row.Cells[i].Text = DocumentStatus.GetName(2); break;
        //                case 3: e.Row.Cells[i].Text = DocumentStatus.GetName(3); break;
        //                default: break;
        //            }
        //        }
        //    }
        //}
    }
}
